package com.fdm.model.accounts;

import java.util.Map;

import com.fdm.model.exceptions.BankManagerException;
import com.fdm.model.exceptions.LessThanZeroException;

public class InterestRateDecorator extends AccountDecorator {

	/**
	 * 
	 */
	private static final long serialVersionUID = 947763010621071864L;
	protected double interestRate = 0.73;
	
	public InterestRateDecorator(_Account decoratedAccount) {
		super(decoratedAccount);
	}

	public double getInterestRate() {
		return this.interestRate;
	}

	public void setInterestRate(Double interestRate) throws LessThanZeroException {
		if (interestRate!=null) {
			if (interestRate>=0)
			{
				this.interestRate = interestRate;
			}
			else throw new LessThanZeroException();
		}
	}
	
	@Override
	public void setAttributes(Map<String, Object> parameters) throws BankManagerException {
		this.setInterestRate( (Double)parameters.get("interestRate"));
	}
}
